home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX Base Documentation 1998 November
/
IRIX 6.5.2 Base Documentation November 1998.img
/
usr
/
share
/
catman
/
u_man
/
cat1
/
getopt.z
/
getopt
Wrap
Text File
|
1998-10-20
|
8KB
|
133 lines
ggggeeeettttoooopppptttt((((1111)))) ggggeeeettttoooopppptttt((((1111))))
NNNNAAAAMMMMEEEE
_gggg_eeee_tttt_oooo_pppp_tttt - parse command options
SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
_ssss_eeee_tttt _----_---- _````_gggg_eeee_tttt_oooo_pppp_tttt _o_p_t_s_t_r_i_n_g _$$$$_****_````
DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
The _gggg_eeee_tttt_oooo_pppp_tttt_ssss(1) command supersedes _gggg_eeee_tttt_oooo_pppp_tttt. For more information, see the
NOTES below.
_gggg_eeee_tttt_oooo_pppp_tttt is used to break up options in command lines for easy parsing by
shell procedures and to check for legal options. It recognizes
supplementary code set characters in the argument given to _o_p_t_s_t_r_i_n_g
according to the locale specified in the _LLLL_CCCC______CCCC_TTTT_YYYY_PPPP_EEEE environment variable
[see _LLLL_AAAA_NNNN_GGGG on _eeee_nnnn_vvvv_iiii_rrrr_oooo_nnnn(5)].
_o_p_t_s_t_r_i_n_g is a string of recognized option letters; see _gggg_eeee_tttt_oooo_pppp_tttt(3C). If a
letter is followed by a colon, the option is expected to have an argument
which may or may not be separated from it by white space. The special
option _----_---- is used to delimit the end of the options. If it is used
explicitly, _gggg_eeee_tttt_oooo_pppp_tttt recognizes it; otherwise, _gggg_eeee_tttt_oooo_pppp_tttt generates it; in
either case, _gggg_eeee_tttt_oooo_pppp_tttt places it at the end of the options. The positional
parameters (_$$$$_1111 _$$$$_2222 ...) of the shell are reset so that each option is
preceded by a _---- and is in its own positional parameter; each option
argument is also parsed into its own positional parameter.
EEEEXXXXAAAAMMMMPPPPLLLLEEEE
The following code fragment shows how one might process the arguments for
a command that can take the options _aaaa or _bbbb, as well as the option _oooo,
which requires an argument:
_ssss_eeee_tttt _----_---- _````_gggg_eeee_tttt_oooo_pppp_tttt _aaaa_bbbb_oooo_:::: _$$$$_****_````
_iiii_ffff _[[[[ _$$$$_???? _!!!!_==== _0000 _]]]]
_tttt_hhhh_eeee_nnnn
_eeee_cccc_hhhh_oooo _$$$$_UUUU_SSSS_AAAA_GGGG_EEEE
_eeee_xxxx_iiii_tttt _2222
_ffff_iiii
_ffff_oooo_rrrr _iiii _iiii_nnnn _$$$$_****
_dddd_oooo
_cccc_aaaa_ssss_eeee _$$$$_iiii _iiii_nnnn
_----_aaaa _|||| _----_bbbb_)))) _FFFF_LLLL_AAAA_GGGG_====_$$$$_iiii_;;;; _ssss_hhhh_iiii_ffff_tttt_;;;;_;;;;
_----_oooo_)))) _OOOO_AAAA_RRRR_GGGG_====_$$$$_2222_;;;; _ssss_hhhh_iiii_ffff_tttt _2222_;;;;_;;;;
_----_----_)))) _ssss_hhhh_iiii_ffff_tttt_;;;; _bbbb_rrrr_eeee_aaaa_kkkk_;;;;_;;;;
_eeee_ssss_aaaa_cccc
_dddd_oooo_nnnn_eeee
This code accepts any of the following as equivalent:
_cccc_mmmm_dddd _----_aaaa_oooo_aaaa_rrrr_gggg _ffff_iiii_llll_eeee _ffff_iiii_llll_eeee
_cccc_mmmm_dddd _----_aaaa _----_oooo _aaaa_rrrr_gggg _ffff_iiii_llll_eeee _ffff_iiii_llll_eeee
_cccc_mmmm_dddd _----_oooo_aaaa_rrrr_gggg _----_aaaa _ffff_iiii_llll_eeee _ffff_iiii_llll_eeee
_cccc_mmmm_dddd _----_aaaa _----_oooo_aaaa_rrrr_gggg _----_---- _ffff_iiii_llll_eeee _ffff_iiii_llll_eeee
PPPPaaaaggggeeee 1111
ggggeeeettttoooopppptttt((((1111)))) ggggeeeettttoooopppptttt((((1111))))
FFFFIIIILLLLEEEESSSS
_////_uuuu_ssss_rrrr_////_llll_iiii_bbbb_////_llll_oooo_cccc_aaaa_llll_eeee_////_l_o_c_a_l_e_////_LLLL_CCCC______MMMM_EEEE_SSSS_SSSS_AAAA_GGGG_EEEE_SSSS_////_uuuu_xxxx_cccc_oooo_rrrr_eeee
language-specific message file [See _LLLL_AAAA_NNNN_GGGG on _eeee_nnnn_vvvv_iiii_rrrr_oooo_nnnn(5).]
SSSSEEEEEEEE AAAALLLLSSSSOOOO
_gggg_eeee_tttt_oooo_pppp_tttt_ssss(1), _ssss_hhhh(1), _gggg_eeee_tttt_oooo_pppp_tttt(3C)
DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
_gggg_eeee_tttt_oooo_pppp_tttt prints an error message on the standard error when it encounters
an option letter not included in _o_p_t_s_t_r_i_n_g.
NNNNOOOOTTTTEEEESSSS
_gggg_eeee_tttt_oooo_pppp_tttt may not be supported in a future release. For this release a
conversion tool has been provided, _gggg_eeee_tttt_oooo_pppp_tttt_cccc_vvvv_tttt. For more information about
_gggg_eeee_tttt_oooo_pppp_tttt_ssss and _gggg_eeee_tttt_oooo_pppp_tttt_cccc_vvvv_tttt, see _gggg_eeee_tttt_oooo_pppp_tttt_ssss(1).
Reset _OOOO_PPPP_TTTT_IIII_NNNN_DDDD to 1 when rescanning the options.
_gggg_eeee_tttt_oooo_pppp_tttt does not support the part of Rule 8 of the command syntax standard
[see _iiii_nnnn_tttt_rrrr_oooo(1)] that permits groups of option-arguments following an
option to be separated by white space and quoted. For example,
_cccc_mmmm_dddd _----_aaaa _----_bbbb _----_oooo _""""_xxxx_xxxx_xxxx _zzzz _yyyy_yyyy_"""" _ffff_iiii_llll_eeee
is not handled correctly. To correct this deficiency, use the _gggg_eeee_tttt_oooo_pppp_tttt_ssss
command in place of _gggg_eeee_tttt_oooo_pppp_tttt.
If an option that takes an option-argument is followed by a value that is
the same as one of the options listed in _o_p_t_s_t_r_i_n_g (referring to the
earlier EXAMPLE section, but using the following command line: _cccc_mmmm_dddd _----_oooo _----_aaaa
_ffff_iiii_llll_eeee), _gggg_eeee_tttt_oooo_pppp_tttt always treats _----_aaaa as an option-argument to _----_oooo; it never
recognizes _----_aaaa as an option. For this case, the _ffff_oooo_rrrr loop in the example
shifts past the _f_i_l_e argument.
PPPPaaaaggggeeee 2222